package com.guangzi.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guangzi.entity.Dynamic;
import com.guangzi.mapper.DynamicDao;
import com.guangzi.service.AbstractService;
import com.guangzi.service.DynamicService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DynamicServiceImpl extends AbstractService implements DynamicService {

    private DynamicDao dynamicDAO;

    @Autowired
    public void setDynamicDAO(DynamicDao dynamicDAO) {
        super.setBaseDAO(dynamicDAO);
        this.dynamicDAO = dynamicDAO;
    }

    @Override
    public void updateStatus(Dynamic dynamic) {
        dynamicDAO.updateStatus(dynamic);
    }

    @Override
    public PageInfo<Dynamic> findAll(int pageNo, int pageSize) {
        PageHelper.startPage(pageNo,pageSize);
        List<Dynamic> list = dynamicDAO.findAll();
        PageInfo<Dynamic> page = new PageInfo<>(list);

        return page;
    }
}
